package com.xinchao.ck_mips.impl;

import android.widget.Toast;

import com.xinchao.ck_mips.App;
import com.xinchao.ck_mips.http.CKRequestSubscriber;
import com.xinchao.ck_mips.model.IBindModel;
import com.xinchao.ck_mips.utils.NetWorkUtil;

/**
 * Created by wq on 2019/4/23.
 */
public class BindModelImpl implements IBindModel {
    @Override
    public void bind(String code, IBindCallbackListener mListener) {
        request(getService().bind(code), new CKRequestSubscriber<Object>() {
            @Override
            protected void onRequestSuccess(Object o) {
                mListener.onSuccessed(o);
            }

            @Override
            protected void onRequestError(Throwable t) {
                super.onRequestError(t);
                mListener.onError(t);
            }

            @Override
            protected void onStart() {
                super.onStart();
                mListener.onStart();
            }

            @Override
            public void onComplete() {
                super.onComplete();
                mListener.onCompleted();
            }
        });
    }

    @Override
    public void register(String deviceName, String ip, long rebootTime, IRegisterCallbackListener mListener) {
        request(getService().register(rebootTime, ip, deviceName), new CKRequestSubscriber<Object>() {
            @Override
            protected void onRequestSuccess(Object s) {
                mListener.onSuccessed((String) s);
            }

            @Override
            protected void onRequestError(Throwable t) {
                super.onRequestError(t);
                mListener.onError(t);
            }
        });
    }

}
